package com.zhuky.controller;

import java.util.Date;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhuky.entity.Resource;
import com.zhuky.entity.User;

@Controller
@RequestMapping("/user")
public class UserController {

	@Autowired
	private Resource resource;
	
	
	@ResponseBody
	@RequestMapping("/resource")
	public Resource resource() {
		Resource bean = new Resource();
		BeanUtils.copyProperties(resource, bean);
		return bean;
	}
	@ResponseBody
	@RequestMapping("/index")
	public User index() {
		
		User user = new User();
		user.setName("Tom2233");
		user.setAge(22);
		user.setBirthday(new Date());
		user.setPassword("123123");
		return user;
	}
	
	@ResponseBody
	@RequestMapping("/error")
	public User error() {
		
		int i=1/0;
		return null;
	}
}
